package com.bentley.kotlindemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import com.bentley.kotlindemo.ui.kits.home.MyAdapter
import com.bentley.kotlindemo.ui.kits.home.OnItemClick

class MringActivity2 : AppCompatActivity(), OnItemClick {

    private var data = ArrayList<String>()
    private var adapter: MyAdapter? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
         // val binding = MringActivity2Binding.inflate(layoutInflater)
        // setContentView(binding.root)
    /*    val binding: ActivityMainBinding =
            DataBindingUtil.setContentView(this, R.layout.activity_mring2)*/
        // setContentView(R.layout.activity_mring2)

        var bol = intent.getBooleanExtra("yud", false)
        // val recyclerview = findViewById<RecyclerView>(R.id.recyclerview);
        val manager = LinearLayoutManager(applicationContext)
      //  binding.recyclerview.layoutManager = manager
        adapter = MyAdapter()
        adapter!!.add(getData())
       // binding.recyclerview.adapter = adapter
        adapter!!.setOnItemClick(this)
        adapter!!.notifyDataSetChanged()

    }

    fun getData(): List<String> {
        for (i in 0..100) {
            data.add("我是第" + i + "个")
        }
        return data
    }

    override fun onItemClick(view: View, position: Int) {
        Toast.makeText(applicationContext, "我是第" + position + "个", Toast.LENGTH_LONG).show()

    }
}